
<template xmlns="http://www.w3.org/1999/html">
  <el-scrollbar height="650px">
    <div class="big-div">
      <el-form-item class="el-form-item01">
        <el-button v-if="job.jobPoststatus == 0" type="primary" style="margin-left: 900px" @click="fabuzt()">发布</el-button>
        <el-button v-if="job.jobPoststatus == 2"  type="primary"  @click="fabuzt2()">重新发布</el-button>
        <el-button type="primary" @click="fanhui()">取消</el-button>
      </el-form-item>
      <div class="div01" >
        用人需求发布
      </div>
      <div style="width: 1160px;padding:0px 40px 10px 0px;margin:auto;margin-top: 10px;background: white">
        <div style="width: 100%;height:50px;border-bottom:1px solid rgb(220, 223, 230);line-height: 50px">
          <div style="height: 30px;width: 5px;margin: 10px 0px 0px 20px;background-color:#118dea;float: left;"></div><span style="margin-left: 10px;">岗位信息</span>
        </div>
        <el-form
            disabled
            :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            :inline="true" :model="job"  label-width="205px" style="margin: 20px 0px 0px 0px">
          <el-form-item label="流程标题">
            <el-input v-model="job.jobTitle"/>
          </el-form-item>
          <el-form-item label="申请部门">
            <el-input v-model="job.deptName" />
            <el-icon/>
          </el-form-item>
          <el-form-item label="申请岗位">
            <el-input v-model="job.postName" />
            <el-icon/>
          </el-form-item>
          <el-form-item label="需求人数" prop="name" style="width: 45%;">
            <el-input  v-model="job.jobNumber"/>
          </el-form-item>
          <el-form-item label="申请发布渠道" prop="name" style="width: 45%;">
            <el-input  v-model="job.sourceName"/>
          </el-form-item>
          <el-form-item label="增补理由" prop="desc" style="width: 95%;">
            <el-input  type="textarea" v-model="job.jobReason"/>
          </el-form-item>

          <el-form-item label="岗位职责" prop="desc" style="width: 95%;">
            <el-input type="textarea" v-model="job.jobPosition"/>
          </el-form-item>
        </el-form>
      </div>
      <div style="width: 1160px;padding:0px 40px 10px 0px;margin:auto;margin-top: 10px;background: white">
        <div style="width: 100%;height:50px;border-bottom:1px solid rgb(220, 223, 230);line-height: 50px">
          <div style="height: 30px;width: 5px;margin: 10px 0px 0px 20px;background-color:#118dea;float: left;"></div><span style="margin-left: 10px;">岗位发布信息</span>
        </div>
        <el-form
            :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            :inline="true" :model="job"  label-width="205px" style="margin: 20px 0px 0px 0px">
          <el-form-item label="发布渠道" prop="region" style="width: 43.5%;">
            <el-select :value="d.sourceList" v-model="jobRecord.recordSourceName"  placeholder="请选择" style="width: 437px;">
              <el-option v-for="a in d.sourceList"
                         :label="a.sourceName"
                         :key="a.sourceName"
                         :value="a.sourceName" />
            </el-select>
          </el-form-item>
          <el-form-item label="发布时间" prop="name" style="width: 45%;">
            <el-input disabled v-model="jobRecord.recordTime" />
          </el-form-item>
          <el-form-item label="发布部门" prop="name" style="width: 45%;">
            <el-input disabled v-model="jobRecord.postName2"/>
          </el-form-item>
          <el-form-item label="发布员工" prop="name" style="width: 45%;">
            <el-input disabled v-model="jobRecord.empName2" />
          </el-form-item>
        </el-form>
      </div>
      <div style="width: 1160px;padding:0px 40px 10px 0px;margin:auto;margin-top: 10px;background: white">
        <div style="width: 100%;height:50px;border-bottom:1px solid rgb(220, 223, 230);line-height: 50px">
          <div style="height: 30px;width: 5px;margin: 10px 0px 0px 20px;background-color:#118dea;float: left;"></div><span style="margin-left: 10px;">招聘要求</span>
        </div>
        <el-form
            disabled
            :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            :inline="true"  label-width="205px" style="margin: 20px 0px 0px 0px">
          <el-form-item label="学历" prop="name" style="float: left;width: 505px;">
            <el-input v-model="job.jobEducation" />
          </el-form-item>
          <el-form-item label="工作经验" prop="name" style="float: left;width: 505px;">
            <el-input v-model="job.jobExperience" />
          </el-form-item>
          <el-form-item label="工作地点" prop="name" style="float: left;width: 505px;">
            <el-input  v-model="job.jobPlace" />
          </el-form-item>
          <el-form-item label="专业" prop="name" style="width: 505px;">
            <el-input  v-model="job.jobTechnology" />
          </el-form-item>
          <el-form-item label="年龄下限" prop="name" style="float: left;width: 505px;">
            <el-input v-model="job.jobOverage" />
          </el-form-item>
          <el-form-item label="年龄上限" prop="name" style="width: 505px;">
            <el-input  v-model="job.jobSalarycap" />
          </el-form-item>
          <el-form-item label="薪资下限" prop="name" style="float: left;width: 505px;">
            <el-input  v-model="job.jobSalaryfloor"  />
          </el-form-item>
          <el-form-item label="薪资上限" prop="name" style="width: 505px;">
            <el-input  v-model="job.jobSalarycap"  />
          </el-form-item>
          <el-form-item label="其他" prop="name" style="width:100%;">
            <el-input v-model="job.jobElse"/>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </el-scrollbar>
</template>

<script lang="ts" setup>
import {onBeforeMount, reactive, ref} from 'vue'
import {ElMessage, ElTable, genFileId} from 'element-plus'
import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus'
import axios from "axios";
import {User} from "@element-plus/icons-vue/dist/types";
import {useStore} from "vuex";
import {useRouter} from "vue-router";



const d = reactive({
  //table当前展示的数据
  list:null,
  //总记录
  total:0,
  //页码
  pageNo:1,
  //页大小
  pageSize:10,
  //数据
  tableData:[],
  //人才渠道数据
  sourceList:[],

})
//获取当前时间
import moment from 'moment';
let riqi = moment(new Date()).format("YYYY-MM-DD hh:mm:ss")

//当前登录者的信息
const store=useStore();
const job = reactive({
  jobId:'',
  jobTitle:'',
  deptName:'',
  postName:'',
  empName:'',
  jobDate:'',
  jobNumber:'',
  jobReason:'',
  sourceName:'',
  jobPosition:'',
  jobEducation:'',
  jobExperience:'',
  jobPlace:'',
  jobLimitage:'',
  jobOverage:'',
  jobSalarycap:'',
  jobSalaryfloor:'',
  jobTechnology:'',
  jobPubdate:'',
  jobPoststatus:'',
  jobElse:'',

})

const postMag = (row) =>{
  //岗位需求id
  job.jobId = row.jobId
  //岗位需求标题
  job.jobTitle = row.jobTitle
  job.deptName = row.sysDept.deptName;
  job.postName = row.sysPost.postName;
  //申请时间
  job.jobDate = row.jobDate
  //需求人数
  job.jobNumber = row.jobNumber
  //需求理由
  job.jobReason = row.jobReason
  //用工来源
  job.sourceName = row.source.sourceName
  //岗位职责
  job.jobPosition = row.jobPosition
  //学历
  job.jobEducation = row.education.educationName
  //工作经验
  job.jobExperience = row.experience.experienceName
  //工作地点
  job.jobPlace = row.jobPlace
  //年龄上限
  job.jobLimitage = row.jobLimitage
  //年龄下限
  job.jobOverage = row.jobOverage
  //薪资上限
  job.jobSalarycap = row.jobSalarycap
  //薪资下限
  job.jobSalaryfloor = row.jobSalaryfloor
  //技术
  job.jobTechnology = row.jobTechnology
  //发布状态
  job.jobPoststatus = row.jobPoststatus
  //其他
  job.jobElse = row.jobElse
  // //发布时间
  // job.recordTime = row.recordTime
  // //发布人姓名
  // job.empName2 = d.qq.jobRecord.employee.empName
  // //发布人部门
  // job.postName2 = row.employee.dept.deptName;
  console.log(row)


}
//查询出所有用工来源
const source =()=>{
  axios.post("personnelOa/source/selectlist")
      .then((res)=>{
        d.sourceList = res.data.data
      })
}
//一进页面就调用
onBeforeMount(()=>{
  source();
  xiangqi();
})

//返回上一级
let router=useRouter();
const fanhui=()=>{
  router.go(-1);
}


//岗位需求传过来的数据jobId
let jobId = router.currentRoute.value.query
//查询需求数据记录
const xiangqi=()=>{
  console.log(jobId)
    axios.post("personnelOa/job/selectjobId/"+jobId["id"])
        .then((res) => {
          console.log("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
           d.tableData = res.data.data;
          console.log(d.tableData)
          postMag(res.data.data);

        })
}
let id = parseInt(<string>jobId["id"])
const jobRecord = reactive({
  jobId:id,
  //发布时间
  recordTime:riqi,
  //发布人
  empName2:store.state.user.sysEmployee.empName,
  //发布人部门
  postName2:store.state.user.sysEmployee.employeePost.post.postName,
  //发布人Id
  empId:store.state.user.sysEmployee.empId,
  recordSourceName:'',
})
//新增一条岗位需求发布记录
let add=ref();
const addJobRecord=()=>{
  axios.post("personnelOa/jobRecord/add",jobRecord)
      .then((res)=>{
        add.value = res.data.data
        if(add.value < 0 ){
          ElMessage({
            type: 'success',
            message: '发布失败',
          })
        }
      })
}
//修改发布状态
let fa = ref();
const fabuzt=()=> {
  console.log(jobRecord)
  axios.post("personnelOa/job/upstatus/" + job.jobId)
      .then((res) => {
        fa.value = res.data.data
        addJobRecord();
        fanhui();
        ElMessage({
          type: 'success',
          message: '发布成功',
        })
      })
}
  //新增一条岗位需求重新记录
  let add2=ref();
  const addJobRecord2=()=>{
    axios.post("personnelOa/jobRecord/add3",jobRecord)
        .then((res)=>{
          add2.value = res.data.data
          if(add2.value < 0 ){
            ElMessage({
              type: 'success',
              message: '发布失败',
            })
          }
        })
  }
//修改重新发布状态
  let fa2 = ref();
  const fabuzt2=()=>{
    console.log(jobRecord)
    axios.post("personnelOa/job/upstatus3/"+job.jobId)
        .then((res)=>{
          fa2.value = res.data.data
          addJobRecord2();
          fanhui();
          ElMessage({
            type: 'success',
            message: '发布成功',
          })
        })
}


</script>


<style scoped>
.el-form--inline .el-form-item{
  margin-right: 0px;
}
body{
  background: #F4F4F4;
}
.big-div{
  /*display:flex;*/
  /*justify-content: center;*/
  flex-wrap: wrap;
  width: 100%;
  background: #F4F4F4;
  margin:0 auto;
}
.el-form-item01{
  height: 80px;background: white;
}
.el-input{
  width: 300px;
}
.div01{
  margin:auto;
  text-align:center;
  line-height: 70px;
  width: 1200px;
  height: 80px;
  margin-top: 20px;
  background: white;
  font-size: 30px;
}
</style>